package utility;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;

/**
 * This class extends the BufferedReader class and overrides the readLine() method.
 * @author HTTPDragon Team
 * @version 1.0
 */
public class BufferedReaderPlus extends BufferedReader{
    
    /**
     * Constructs a buffered reader.
     * @param r Contains a Reader type 
     */
    public BufferedReaderPlus(Reader r){
        super(r);
    }  
    
    /**
     * This method returns the next line in the Buffer.
     * @return A String.
     */
    public String readLine() throws IOException{
        StringBuilder result= new StringBuilder();
            int huidige=-1, vorige = -1;
            do{
                if(huidige!=-1)
                    vorige = huidige;
                huidige = super.read();
                result.append((char)huidige);
            }while(vorige!=13 && huidige!=10 & super.ready());            
             if(result.length()==0)
                 return null;
            return result.toString();  
    }
}
